<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{if isset($SEO['title']) && !empty($SEO['title'])}{$SEO['title']}{/if}{$SEO['site_title']}</title>
<meta name="Keywords" content="{$SEO['keyword']}" />
<meta name="Description" content="{$SEO['description']}" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<script type="text/javascript" src="{THEME_PATH}js/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="{THEME_PATH}style/appStyle.css" />
</head>
<body>
<div class="app_head"> <a class="app_headLeft" href="javascript:void(0);"><img src="{THEME_PATH}images/app_head_user.svg"/></a>
  <h1 class="app_hdTitle">金商道</h1>
  <a class="app_headRight" href="/index.php?m=union&c=union&a=index"><img src="{THEME_PATH}images/app_head_fangdajing.svg" /></a> </div>
<div id="bannerParent" class="app_banner">
  <ul>
  {hd:focus action="lists" num="5" order="sort ASC, id DESC" }
    {loop $data $r}
    {if $r[pic]}
    <li> <a href="{$r[url]}"><img src="{$r[pic]}" /></a> </li>
    {/if}
    {/loop}
    {/hd}
  </ul>
  <div class="app_change">
    <ul style="display:none;">
    </ul>
    <div class="app_gonggao"> <img src="{THEME_PATH}images/app_gonggao_img.svg" /> <a class="app_moreA" href="/index.php?m=article&c=index&a=lists&id=7">更多</a>
      <ul>
      {hd:article action="lists" num="5" order="id DESC"}
          {php $i = 0;}
          {loop $data $r}
          {php $i++;}
    <li> <a href="{U('Article/Index/detail', array('id'=> $r[id]))}">
          <p class="app_userId">{msubstr($r[title],27)}</p>
          </a> </li>
    {/loop}
    {/hd}
      </ul>
    </div>
  </div>
</div>
<ul class="app_navList">
  <li> <a href="{U('Goods/Index/category')}">
    <p class="p1"></p>
    <span>全部商品</span> </a> </li>
  <li> <a href="{U('league/league/index')}">
    <p class="p2"></p>
    <span>申请入驻</span> </a> </li>
  <li> <a href="{U('Help/Help/detail',array('id'=>18))}">
    <p class="p3"></p>
    <span>赠送计划</span> </a> </li>
  <li> <a href="{U('Help/Help/detail',array('id'=>25))}">
    <p class="p4"></p>
    <span>新手课堂</span> </a> </li>
</ul>
<div class="app_ruzhu">
  <h1> <span>最新入驻</span> <a href="{U('Union/Union/index')}">更多</a> </h1>
  <div>
    <ul class="app_rzList">
      {hd:union action="lists" num="3" where="$_where"  order=" id desc"}
    {loop $data $r}
    <li> <a href="{U('union/union/detail', array('id'=> $r[id]))}"> {if empty($r[company_logo])} <img src="{THEME_PATH}images/nopic.jpg"  /> {else} <img src="{$r[company_logo]}"/> {/if}
        <p>{$r[company_name]}</p>
        </a> </li>
    {/loop}
    {/hd}
    </ul>
  </div>
</div>
<div class="app_sellRuZhu">
  <h1>商家入驻</h1>
  <p>已入驻商家<span> {ALL_SELL} </span>家</p>
  <ul class="app_srzList">
   {hd:union action="lists" num="6" where="$_where"  order=" id desc"}
    {loop $data $r}
    <li> <a href="{U('union/union/detail', array('id'=> $r[id]))}"> {if empty($r[company_logo])} <img src="{THEME_PATH}images/nopic.jpg"  /> {else} <img src="{$r[company_logo]}"/> {/if}
        <h1>{$r[company_name]}</h1>
        </a> </li>
    {/loop}
    {/hd}
  </ul>
</div>
<div class="app_userPanel">
  <div class="app_userInfo">
   {if is_login() > 0}
  	 <?php $arr = getUserInfo(is_login());?>
    <img src="{if $arr[ico]}<?php echo $arr[ico];?>{else}{THEME_PATH}img/head.png{/if}" />
        <h1><?php echo $arr["user_type"]==1?"个人会员":"商家会员";?>：<?php echo $arr["username"]?></h1>
    {else}
   <img src="{THEME_PATH}img/head.png" />
        <h1>还未登录</h1>
    {/if}
  </div>
  <ul class="app_userNav">
     <li><a href="{U('User/Index/index')}">我的账户</a></li>
              <li><a href="{U('User/Order/orderdown')}">我的订单</a></li>
              <li><a href="{U('User/user/userinfo')}">个人设置</a></li>
               <li><a href="{{U('User/Public/logout')}">退出账户</a></li>
  </ul>
</div>

<script type="text/javascript">
$(function()
{
	$(".app_headLeft").click(function()
	{
		var userDisplay = $(".app_userPanel").css("left");
		if(userDisplay != "0px")
		{
			$(".app_userPanel").animate({left:0});
		}
		else{
			$(".app_userPanel").animate({left:"-150px"});
		}
	});
});
$(function()//banner图片切换
{
	var setIndex = 0;
	var mediaWid = $(window).width();
	$(".app_banner > ul > li").css("width",mediaWid + "px");
	for(var i=0;i<$(".app_banner > ul > li").length;i++)
	{
		var oLi = document.createElement("li");
		$(".app_change > ul").get(0).appendChild(oLi);
	}
	$(".app_banner > ul").css("width" , mediaWid * $(".app_banner > ul > li").length);
	$(".app_change > ul > li").click(function()
	{
		var clickIndex = $(this).index();
		setIndex = clickIndex;
		$(".app_banner > ul").animate({marginLeft : -(mediaWid * clickIndex)});
		$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
		$(this).css({opacity:1 , backgroundColor:"#007aff"});
	});
	function setBannerChange()
	{
		if(setIndex <$(".app_banner > ul > li").length)
		{
			$(".app_banner > ul").animate({marginLeft : -(mediaWid * setIndex)});
			$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
			$(".app_change > ul > li").eq(setIndex).css({opacity:1 , backgroundColor:"#007aff"});
			setIndex++;
		}
		else{
			setIndex = 0;
			$(".app_banner > ul").animate({marginLeft : -(mediaWid * setIndex)});
			$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
			$(".app_change > ul > li").eq(setIndex).css({opacity:1 , backgroundColor:"#007aff"});
		}
	}
	var setBanner = setInterval(setBannerChange,3000); 
	var _x;//鼠标离控件左上角的相对位置
	var _move=false;//移动标记 
	/*for(var i=0;i<$(".app_banner > ul > li > a").length;i++)
	{
		$(".app_banner > ul > li > a").get(i).onmousedown = function(event)
		{
			event.preventDefault();
			clearInterval(setBanner);
			app_bannerIndex=$(this).parent().index();	
			_move=true;
			_x=event.pageX;
			bannerUlMargin = parseInt($(".app_banner > ul").css("margin-left"));
			var oDateDown = new Date();
			var msLengthDown , sLengthDown , mLengthDown;
			if(String(oDateDown.getMilliseconds()).length == 2)
			{
				msLengthDown = String("0") + String(oDateDown.getMilliseconds());
			}
			else if(String(oDateDown.getMilliseconds()).length == 1)
			{
				msLengthDown = String("00") + String(oDateDown.getMilliseconds());
			}
			else{
				msLengthDown = String(oDateDown.getMilliseconds());
			}
			if(String(oDateDown.getSeconds()).length == 1)
			{
				sLengthDown = String("0") + String(oDateDown.getSeconds());
			}
			else{
				sLengthDown = String(oDateDown.getSeconds());
			}
			mLengthDown = String(oDateDown.getMinutes());
			mssmDateDown = mLengthDown + sLengthDown + msLengthDown;
		};
	}
	document.onmousemove = function(e)
	{
		e.cancelBubble=true;
        e.returnValue = false;
		if(_move){  
            var x=e.pageX-_x;//移动时根据鼠标位置计算控件左上角的绝对位置
			$(".app_banner > ul").css("margin-left" , bannerUlMargin + x);
        }
	}
	document.onmouseup = function()
	{
		_move=false;
		var changeMargin = parseInt($(".app_banner > ul").css("margin-left")) - bannerUlMargin;
		var oDateUp = new Date();
		var msLengthUp , sLengthUp , mLengthUp;
		if(String(oDateUp.getMilliseconds()).length == 2)
		{
			msLengthUp = String("0") + String(oDateUp.getMilliseconds());
		}
		else if(String(oDateUp.getMilliseconds()).length == 1)
		{
			msLengthUp = String("00") + String(oDateUp.getMilliseconds());
		}
		else{
			msLengthUp = String(oDateUp.getMilliseconds());
		}
		if(String(oDateUp.getSeconds()).length == 1)
		{
			sLengthUp = String("0") + String(oDateUp.getSeconds());
		}
		else{
			sLengthUp = String(oDateUp.getSeconds());
		}
		mLengthUp = String(oDateUp.getMinutes());
		var mssmDateUp = mLengthUp + sLengthUp + msLengthUp;
		var dateCha = mssmDateUp - mssmDateDown;
		if(changeMargin > 20)
		{
			if(app_bannerIndex > 0)
			{
				if(dateCha <= 500)
				{
					$(".app_banner > ul").animate({marginLeft: -(mediaWid * (app_bannerIndex - 1))});
					$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
					$(".app_change > ul > li").eq(app_bannerIndex - 1).css({opacity:1 , backgroundColor:"#007aff"});
				}
				else{
					$(".app_banner > ul").animate({marginLeft: bannerUlMargin});
				}
			}
			else{
				$(".app_banner > ul").animate({marginLeft: bannerUlMargin});
			}
		}
		else if(changeMargin < -20)
		{
			if(app_bannerIndex < $(".app_banner > ul > li").length - 1)
			{
				if(dateCha <= 500)
				{
					$(".app_banner > ul").animate({marginLeft: -(mediaWid * (app_bannerIndex + 1))});
					$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
					$(".app_change > ul > li").eq(app_bannerIndex + 1).css({opacity:1 , backgroundColor:"#007aff"});
				}
				else{
					$(".app_banner > ul").animate({marginLeft: bannerUlMargin});
				}
			}
			else{
				$(".app_banner > ul").animate({marginLeft: bannerUlMargin});
			}
		}
		else{
			$(".app_banner > ul").animate({marginLeft: bannerUlMargin});
		}
	}
	for(var i=0; i<$(".app_banner > ul > li > a").length;i++)
	{
		$(".app_banner > ul > li > a").get(i).onmouseup=function(event)
		{
			var moveAX = _x - event.pageX;
			if(moveAX == 0)
			{
				$(".app_banner > ul > li > a").unbind("click");
			}
			else{
				//$(this).attr("href",bannerHref);
			}
		}
	}
	$(".app_banner > ul > li > a").bind("click",function(e)
	{
		return false;
	});
	$(".app_banner > ul > li > a").mouseup(function()
	{
		setBanner = setInterval(setBannerChange,3000);
	});*/
	var bl = false;
	var bannerList = document.getElementById("bannerParent").getElementsByTagName("li");
	function tStart(event)
	{
		event.preventDefault();
		t_bannerIndex = $(this).index();
		t_bannerUlMargin = parseInt($(".app_banner > ul").css("margin-left"));
		clearInterval(setBanner);
		if(event.targetTouches.length == 1)
		{
			startX =  event.targetTouches[0].pageX;
		}
	}
	function tMove(event)
	{
		event.preventDefault();
		if(event.targetTouches.length == 1)
		{
			bl = true;
			var tx = event.targetTouches[0].pageX - startX;
			$(".app_banner > ul").css("margin-left" , t_bannerUlMargin + tx);
		}
	}
	for(var i=0;i<bannerList.length;i++)
	{
		bannerList[i].addEventListener("touchstart",tStart,false);
		bannerList[i].addEventListener("touchmove",tMove,false);
		bannerList[i].addEventListener("touchend",function()
		{
			if(bl)
			{
				var moveX = event.changedTouches[0].pageX;
				var cha = moveX - startX;
				if(cha < -20)
				{
					if(t_bannerIndex < $(".app_banner > ul > li").length - 1)
					{
						$(".app_banner > ul").animate({marginLeft: -(mediaWid * (t_bannerIndex + 1))});
						$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
						$(".app_change > ul > li").eq(t_bannerIndex + 1).css({opacity:1 , backgroundColor:"#007aff"});
					}
					else{
						$(".app_banner > ul").animate({marginLeft: t_bannerUlMargin});
					}
				}
				else if(cha > 20)
				{
					if(t_bannerIndex > 0)
					{
						$(".app_banner > ul").animate({marginLeft: -(mediaWid * (t_bannerIndex - 1))});
						$(".app_change > ul > li").css({opacity:0.2 , backgroundColor:"#000"});
						$(".app_change > ul > li").eq(t_bannerIndex - 1).css({opacity:1 , backgroundColor:"#007aff"});
					}
					else{
						$(".app_banner > ul").animate({marginLeft: t_bannerUlMargin});
					}
				}
				else{
					for(var i=0;i<bannerList.length;i++)
					{
						bannerList[i].removeEventListener("touchstart",tStart);
					}
				}
			}
			setBanner = setInterval(setBannerChange,3000);
		},false);
	}
});

function newChange()//控制公告滚动
{
	$(".app_gonggao > ul").animate({marginTop:"-29px"},function()
	{
		var oli=$(".app_gonggao > ul > li").get(0).cloneNode(true);
		$(".app_gonggao > ul").get(0).appendChild(oli);
		$(".app_gonggao > ul").get(0).removeChild($(".app_gonggao > ul > li").get(0));
		$(".app_gonggao > ul").css("margin-top","0");
	});
}
$(function()
{
	var setNewId = setInterval("newChange()",2000);
	$(".app_gonggao > ul").hover(function()
	{
		clearInterval(setNewId);
	},function()
	{
		setNewId = setInterval("newChange()",2000);
	});
});
</script>
<!--{subtemplate common/footer}-->